import { ProFormSlider } from '@ant-design/pro-components';
import { type ProFormSliderProps } from '@ant-design/pro-form/lib/components/Slider';

const CommonFormSlider: React.FC<ProFormSliderProps> = ({ required, rules = [], ...props }) => {
  return (
    <ProFormSlider
      {...props}
      rules={
        rules.some((rule) => 'required' in rule)
          ? rules
          : [
              {
                required,
                message: `请输入${props.label}`,
              },
              ...rules,
            ]
      }
    />
  );
};

CommonFormSlider.defaultProps = { required: false, placeholder: '' };

export default CommonFormSlider;
